package de.unifa.elostplugin.handlers;

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.handlers.HandlerUtil;

import de.unifa.elostplugin.gui.wizards.BuildWizard;
import de.unifa.elostplugin.gui.wizards.beans.BuildBeanData;
import de.unifa.elostplugin.gui.wizards.beans.BuildBeanDecision;

public class BuildHandler extends ElostBaseHandler {

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		Shell shell = HandlerUtil.getActiveShell(event);
		IResource resource = getCurrentResource(event);
		IResource buildBat = resource.getProject().findMember("paanw_ant.bat");

		if (buildBat != null) {
			BuildWizard wizard = new BuildWizard();
			WizardDialog dialog = new WizardDialog(shell, wizard);
			dialog.open();
			
				
		} else {
			MessageDialog.openInformation(shell, "Bauen",
					"Es wurde keine paanw_ant.bat im Rootverzeichnis des Projekts "
							+ resource.getProject().getName() + " gefunden");
		}

		return null;
	}
	
	public void build(BuildBeanDecision decision, BuildBeanData data){
		
	}

}
